package com.ty.user.starter.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class MD5Utils {
    private MD5Utils() {
    }

    public static final String ALGORITHM_NMA = "MD5";
    public static final Integer HASH_ITERATIONS = 2;

    /**
     * 加密
     *
     * @param pwd  原始密码
     * @param salt 盐
     * @return
     */
    public static String encodePassword(String pwd, String salt) {
        return new SimpleHash(ALGORITHM_NMA, pwd, ByteSource.Util.bytes(salt), HASH_ITERATIONS).toHex();
    }
}
